package htmlunit.processon;

import com.gargoylesoftware.htmlunit.BrowserVersion;
import com.gargoylesoftware.htmlunit.WebClient;
import com.gargoylesoftware.htmlunit.html.DomElement;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
import com.me.common.util.SleepUtil;

/**
 * HtmlUnit 实现 ProcessOn 自动注册
 *
 * @author ME
 * @date 2021/5/25
 */
public class AutoRegister {

    public static void main(String[] args) throws Exception {
        WebClient webClient = new WebClient(BrowserVersion.CHROME);
        // 开始请求网站
        HtmlPage page = webClient.getPage("https://gitee.com");
        //点击首页上的登陆按钮，跳转到登陆页面
        HtmlPage loginPage = ((DomElement) page.getByXPath("/html/body/header/div/div/div[5]/a[1]").get(0)).click();
        System.out.println(loginPage);

        SleepUtil.seconds(50);
    }

}
